package com.chen.results;

import com.chen.constant.ResultConstant;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
//data
public class ResultBody<T> {
    private String msg;
    private String jwt;
    private T data;

    public static <T> ResultBody<T> successLogin(T data, String jwt) {
        ResultBody resultBody = new ResultBody();
        resultBody.setMsg(ResultConstant.MSG_SUCCESS);
        resultBody.setJwt(jwt);
        resultBody.setData(data);
        return resultBody;
    }

    public static <T> ResultBody<T> success(T data) {
        ResultBody resultBody = new ResultBody();
        resultBody.setMsg(ResultConstant.MSG_SUCCESS);
        resultBody.setData(data);
        return resultBody;
    }

    public static <T> ResultBody<T> success() {
        ResultBody resultBody = new ResultBody();
        resultBody.setMsg(ResultConstant.MSG_SUCCESS);
        return resultBody;
    }

    public static ResultBody error(String msg) {
        ResultBody resultBody = new ResultBody();
        resultBody.setMsg(msg);
        return resultBody;
    }


}
